﻿using System;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Data;

namespace WAD.DAL
{
    /// <summary>
    /// 广告分享名额操作
    /// </summary>
    public class DAOFCSharedUser : DAO
    {
        public static int Update(int user_id, int article_id)
        {
            Database database = GetDatabase();
            DbCommand cmd = database.GetStoredProcCommand("FCSharedUser_Update");
            database.AddInParameter(cmd, "@user_id", DbType.Int32, user_id);
            database.AddInParameter(cmd, "@article_id", DbType.Int32, article_id);
            database.AddOutParameter(cmd, "@code", DbType.Int32, 4);
            //object o= database.ExecuteScalar(cmd);
            //if (o != null)
            //    return Convert.ToInt32(o);
            //return 0;

            database.ExecuteNonQuery(cmd);
            object o = database.GetParameterValue(cmd, "code");
            if (o != null)
                return Convert.ToInt32(o);
            return 0;
        }
    }
}